package com.link.base.task;

import com.link.base.base.sms.service.SignatureService;
import com.link.base.base.sms.service.TemplateService;
import com.link.base.core.basic.config.xxljob.BaseLinkJobHandler;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 短信模版和签名同步至腾讯云
 * 
 * @author wangyan
 * @date 2018/12/05 21:10
 */
@JobHandler(value = "taskSigAndTempStatus") 
@Component
public class TaskSigAndTempStatus extends BaseLinkJobHandler {
    @Resource
    private TemplateService templateService;

    @Resource
    private SignatureService signatureService;

    @Override
    public ReturnT<String> execute(String params) throws Exception {
        try {
            XxlJobLogger.log("TaskUpdateSignatureStatus");
            super.setLogin(params);
            templateService.syncTencentStatus();
            signatureService.syncTencentStatus();
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            XxlJobLogger.log(e.getMessage());
            return ReturnT.FAIL;
        }
    }
}
